﻿CREATE  PROCEDURE [dbo].[state_CheckForBrokenPTP]
	@NoteID int
AS

RETURN
DECLARE @LoanID int SELECT @LoanID = LoanID FROM t_Note WHERE ID = @NoteID
DECLARE @BPTP_Max int SET @BPTP_Max = ISNULL(CONVERT(int,dbo.fs_StateParamValue((SELECT StatusID FROM t_Note WHERE ID = @NoteID),dbo.fs_StateParamID__BrokenPTPMax())),3)
--RAISERROR('state_CheckForBrokenPTP %d',16,1,@LoanID)
IF (SELECT COUNT(*) FROM t_Note WHERE (LoanID = @LoanID) AND (StatusID = dbo.fs_StateID__Notes__BrokenPromise())) < @BPTP_Max RETURN
EXEC state_Loan_ToRepo @LoanID



